package pkg.genericity.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Utils {

	private static List<String> exclusionlist;
	
	public static List<String> getExclusions()
	{
		if (exclusionlist == null) {
			exclusionlist= new ArrayList<String>();
			exclusionlist.add("id");
			exclusionlist.add("serialVersionUID");
		}
		return exclusionlist;
	}
	
	/**
	 * Returns a comma separated string with the types next to them for all the array elements
	 * @param arr
	 * @param type
	 * @return
	 */
	public static synchronized String createCSVStr(String[] arr, String type) {
		if (type==null) {
			type="";
		}
		String csv="";
		for(String s:arr) {
			csv+=s+" "+type+",";
		}
		
		return csv.substring(0,csv.lastIndexOf(","));
	}
	
	/**
	 * Returns Array1 - Array2
	 * @param arr1
	 * @param arr2
	 * @return
	 */
	public String[] compareArrays(String []arr1, String []arr2)
	{
		String []diff = new String[arr1.length];
		int i=0;
		for (String str1:arr1) {
			boolean found=false;
			for (String str2: arr2) {
				if(str1.toLowerCase().equals(str2.toLowerCase())) {
					found=true;
					break;
				}
			}
			if (! found)  diff[i++]=str1;
		}
		return Arrays.copyOf(diff,i);
	}

}
